﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Se.Framework.Common
{
    public interface IObjectRegistry
    {
        T Resolve<T>()
            where T : class;

        T Resolve<T>(string name)
            where T : class;

        object Resolve(Type type, string name);

        object Resolve(Type type);

        IEnumerable<object> ResolveAll(Type type);

        Lazy<object> ResolveLazy(Type type);

        Lazy<object> ResolveLazy(Type type, string name);

        Lazy<T> ResolveLazy<T>() where T : class;

        Lazy<T> ResolveLazy<T>(string name) where T : class;

        /// <summary>
        /// Registers the instance.
        /// </summary>
        /// <param name="typeFrom">The type from.</param>
        /// <param name="instanceTo">The instance to.</param>
        void RegisterInstance(System.Type typeFrom, object instanceTo);

        //void RegisterInstance<TTypeFrom>(TTypeFrom instanceTo);

        /// <summary>
        /// Registers the instance with a name.
        /// </summary>
        /// <param name="typeFrom">The type from.</param>
        /// <param name="name">The name of the registration.</param>
        /// <param name="instanceTo">The instance to.</param>
        void RegisterInstance(Type typeFrom, string name, object instanceTo);

        void RegisterType(Type typeFrom);

        void RegisterType(Type typeFrom, Type typeTo);

        void RegisterType<TFrom>();

        void RegisterType<TFrom, TTo>();

        /// <summary>
        /// Resets this instance.
        /// </summary>
        void Reset();
        /// <summary>
        /// Cleans the given object
        /// </summary>
        /// <param name="instance"></param>
        void Clean(object instance);

        bool IsRegistered(Type type, string name);

        bool IsRegistered(Type type);

        bool IsRegistered<T>()
            where T : class;

        bool IsRegistered<T>(string name)
            where T : class;

    }
}